package com.kehao.newcoder;

import com.kehao.leetcode.middle.tree_graph.MiddleOrderIterateSolution;
import org.junit.Test;

public class NC36Solution {
    public int findMedianinTwoSortedAray (int[] arr1, int[] arr2) {
        int midPos = (arr1.length+arr2.length-1)/2+1;
        int i1=0,i2=0;
        int i =0;
        int op = 0;
        while (i<midPos){
            i++;
            if(arr1[i1]<arr2[i2]){
                i1++;
                op =1;
            }else {
                i2++;
                op =2;
            }
        }
        if(op==1){
            return arr1[i1-1];
        }else {
            return arr2[i2-1];
        }

    }

    @Test
    public void test01(){
        int[] arr1 = {0,1,2},arr2= {3,4,5};
        int result = findMedianinTwoSortedAray(arr1, arr2);
        System.out.println(result);
    }
}
